package com.clds.kotlinforbusinesslisting.activity

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import com.clds.kotlinforbusinesslisting.R
import com.clds.kotlinforbusinesslisting.base.BaseApplication
import retrofit2.Retrofit
import javax.inject.Inject

class MainActivity : AppCompatActivity() {
    //被注入的变量
    @Inject
    lateinit var retrofit: Retrofit

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        //注入
        BaseApplication.instance.component.inject(this)

        println("Hash值+${retrofit.hashCode()} ")

        var text = findViewById(R.id.text) as TextView;
        var hello = "hello"
        text.text = "$hello world"
        //匿名类
        text.setOnClickListener { v ->
            startActivity(Intent(this, TwoActivity::class.java))
            text.text= retrofit.hashCode().toString();

        }


    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
    }
}
